5fc2bc652d325b3bd38226d3c6ececb9eaa884c8,jsmpp-examples/src/main/java/org/jsmpp/examples/SubmitMultiExample.java,SubmitMultiExample,main,#String[]#,50
Before Change
session.setMessageReceiverListener(new MessageReceiverListenerImpl());
// Bind to the Server
session.connectAndBind("localhost", 8056,
new BindParameter(BindType.BIND_TRX, "test",
"test", "cp",
TypeOfNumber.UNKNOWN,
NumberingPlanIndicator.UNKNOWN,
null));
} catch (IOException e) {
System.err.println("Failed connect and bind to host");
e.printStackTrace();
}
try {
Address address1 = new Address(TypeOfNumber.INTERNATIONAL, NumberingPlanIndicator.UNKNOWN, "628176504657");
Address address2 = new Address(TypeOfNumber.INTERNATIONAL, NumberingPlanIndicator.UNKNOWN, "628176504658");
Address[] addresses = new Address[] {address1, address2};
SubmitMultiResult result = session.submitMultiple("CMT", TypeOfNumber.INTERNATIONAL, NumberingPlanIndicator.UNKNOWN, "1616",
addresses, new ESMClass(), (byte)0, (byte)1, timeFormatter.format(new Date()), null,
new RegisteredDelivery(SMSCDeliveryReceipt.FAILURE), ReplaceIfPresentFlag.REPLACE,
new GeneralDataCoding(Alphabet.ALPHA_DEFAULT, MessageClass.CLASS1, false), (byte)0,
"jSMPP simplify SMPP on Java platform".getBytes());
System.out.println("Messages submitted, result is " + result);
Thread.sleep(2000);
} catch (PDUException e) {
// Invalid PDU parameter
System.err.println("Invalid PDU parameter");
e.printStackTrace();
} catch (ResponseTimeoutException e) {
// Response timeout
System.err.println("Response timeout");
e.printStackTrace();
} catch (InvalidResponseException e) {
// Invalid response
System.err.println("Receive invalid respose");
e.printStackTrace();
} catch (NegativeResponseException e) {
// Receiving negative response (non-zero command_status)
System.err.println("Receive negative response");
e.printStackTrace();
} catch (IOException e) {
System.err.println("IO error occur");
e.printStackTrace();
} catch (InterruptedException e) {
System.err.println("Thread interrupted");
e.printStackTrace();
}
After Change
// Create a new SMPP Session
SMPPSession session = new SMPPSession();
try {
session.setMessageReceiverListener(new MessageReceiverListenerImpl());
// Bind to the Server
String systemId = session.connectAndBind("localhost", 8056,
new BindParameter(BindType.BIND_TRX, "test",
"test", "cp",
TypeOfNumber.UNKNOWN,
NumberingPlanIndicator.UNKNOWN,
null));
LOGGER.info("Connected with SMSC with system id {}", systemId);
try {
Address address1 = new Address(TypeOfNumber.INTERNATIONAL, NumberingPlanIndicator.UNKNOWN, "628176504657");
Address address2 = new Address(TypeOfNumber.INTERNATIONAL, NumberingPlanIndicator.UNKNOWN, "628176504658");
Address[] addresses = new Address[] {address1, address2};
SubmitMultiResult result = session.submitMultiple("CMT", TypeOfNumber.INTERNATIONAL, NumberingPlanIndicator.UNKNOWN, "1616",
addresses, new ESMClass(), (byte)0, (byte)1, TIME_FORMATTER.format(new Date()), null,
new RegisteredDelivery(SMSCDeliveryReceipt.FAILURE), ReplaceIfPresentFlag.REPLACE,
new GeneralDataCoding(Alphabet.ALPHA_DEFAULT, MessageClass.CLASS1, false), (byte)0,
"jSMPP simplify SMPP on Java platform".getBytes());
LOGGER.info("Messages submitted, result is {}", result);
Thread.sleep(2000);
} catch (PDUException e) {
// Invalid PDU parameter
LOGGER.error("Invalid PDU parameter", e);
} catch (ResponseTimeoutException e) {
// Response timeout
LOGGER.error("Response timeout", e);
} catch (InvalidResponseException e) {
// Invalid response
LOGGER.error("Receive invalid response", e);
} catch (NegativeResponseException e) {
// Receiving negative response (non-zero command_status)
LOGGER.error("Receive negative response", e);
} catch (IOException e) {
LOGGER.error("I/O error occured", e);
} catch (InterruptedException e) {
LOGGER.error("Thread interrupted", e);
}
session.unbindAndClose();
} catch (IOException e) {
LOGGER.error("Failed connect and bind to host", e);
}
}
}